package com.prj.dy.datamgr.undo
{
	public class DYXmlDataChangeCmd extends CommandBase
	{
		public function DYXmlDataChangeCmd(xmlOrg:XML, xmlNew:XML, property:String)
		{
			super();
			
			this.orgXmlRef = xmlOrg;
			this.orgXmlCopy = xmlOrg.copy();			
			this.newXml = xmlNew;
			
			this.propertyName = property;
		}
		
		override public function execute():Boolean			
		{		
			if (newXml && orgXmlRef && propertyName)
			{
				orgXmlRef[propertyName] = newXml[propertyName];				
				return true;
			}
			return false;
		}
		
		override public function unExecute():Boolean			
		{
			if (newXml && orgXmlRef && propertyName)
			{
				orgXmlRef[propertyName] = orgXmlCopy[propertyName];				
				return true;
			}			
			
			return false;
		}		
		
		
		
		private var _orgXmlCopy:XML = null;

		public function get orgXmlCopy():XML
		{
			return _orgXmlCopy;
		}

		public function set orgXmlCopy(value:XML):void
		{
			_orgXmlCopy = value;
		}
		
						
		private var _orgXmlRef:XML = null;
		
		public function get orgXmlRef():XML
		{
			return _orgXmlRef;
		}
		
		public function set orgXmlRef(value:XML):void
		{
			_orgXmlRef = value;
		}
		
		
		private var _newXml:XML = null;
		
		public function get newXml():XML
		{
			return _newXml;
		}
		
		public function set newXml(value:XML):void
		{
			_newXml = value;
		}
		
		private var _propertyName:String = null;
		
		public function get propertyName():String
		{
			return _propertyName;
		}
		
		public function set propertyName(value:String):void
		{
			_propertyName = value;
		}
				
		
	}
}